package com.org.manhu.chargehelper.ui;

import java.util.Timer;
import java.util.TimerTask;

import com.org.manhu.chargehelper.ChargeApplication;
import com.org.manhu.chargehelper.R;
import com.org.manhu.chargehelper.service.ServerService;
import com.org.manhu.chargehelper.tools.AppManager;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/**
 * @文件名：SplashActivity.java
 * @包名：com.org.manhu.chargehelper.ui
 * @作者：李朋辉            @QQ：892839211
 * @创建时间：2015年2月5日   上午10:54:27
 *
 * @描述：
 */
public class SplashActivity extends Activity {

	private Timer timer = new Timer();
	private TimerTask task;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_splash);
		AppManager.getAppManager().addActivity(this);
		
//		Intent intent = new Intent(this, ServerService.class);
//		startService(intent);
		
		ChargeApplication.isBoxConnected = true;
		
		task = new TimerTask() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				Intent intent = new Intent(SplashActivity.this,
						HomeActivity.class);
				startActivity(intent);
				finish();
			}
		};
		
		timer.schedule(task, 5000);
	}
	
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
		AppManager.getAppManager().AppExit(this);
		timer.cancel();
	}
}
